package com.starry.compose_study.compositionlocal

import androidx.compose.foundation.layout.Column
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.platform.LocalContext
import com.starry.compose_study.R

@Composable
fun Sample() {
    MaterialTheme {
        Column {
            Text(text = "hello world hello world hello world ")
            CompositionLocalProvider(LocalContentColor provides LocalContentColor.current.copy(alpha = 0.73f)) {
                Text(text = "hello world hello world hello world ")
                Text(text = "hello world hello world hello world ")
                CompositionLocalProvider(
                    LocalContentColor provides LocalContentColor.current.copy(
                        alpha = 0.37f
                    )
                ) {
                    Text(text = "hello world hello world hello world ")
                    Text(text = "hello world hello world hello world ")
                }
                Text(text = "hello world hello world hello world ")
                Text(text = "hello world hello world hello world ")
            }
            Text(text = "hello world hello world hello world ")
            Text(text = "hello world hello world hello world ")
            FruitText(size = 3)
        }
    }
}

@Composable
fun FruitText(size: Int) {

    val resources = LocalContext.current.resources
    val text = resources.getString(R.string.app_name)
    Text(text = "$size  $text")
}